/**
 * ©2013-2015 Alan L. Rights Reserved.
 */
package org.freedom.railhunter.model;

import java.io.Serializable;
import java.util.List;

/**
 *
 * @author Alan
 */
public class OrderTicketInfo implements Serializable {
    
    private String onlyId;
    
    private String seatType;
    
    private String seatTypeName;
    
    private String ticketType;
    
    private String ticketTypeName;
    
    private String passengerName;
    
    private String passengerIdType;
    
    private String passengerIdTypeName;
    
    private String passengerIdNo;
    
    private String passengerPhoneNo;

    public String getOnlyId() {
        return onlyId;
    }

    public void setOnlyId(String onlyId) {
        this.onlyId = onlyId;
    }

    public String getSeatType() {
        return seatType;
    }

    public void setSeatType(String seatType) {
        this.seatType = seatType;
    }

    public String getSeatTypeName() {
        return seatTypeName;
    }

    public void setSeatTypeName(String seatTypeName) {
        this.seatTypeName = seatTypeName;
    }

    public String getTicketType() {
        return ticketType;
    }

    public void setTicketType(String ticketType) {
        this.ticketType = ticketType;
    }

    public String getTicketTypeName() {
        return ticketTypeName;
    }

    public void setTicketTypeName(String ticketTypeName) {
        this.ticketTypeName = ticketTypeName;
    }

    public String getPassengerName() {
        return passengerName;
    }

    public void setPassengerName(String passengerName) {
        this.passengerName = passengerName;
    }

    public String getPassengerIdType() {
        return passengerIdType;
    }

    public void setPassengerIdType(String passengerIdType) {
        this.passengerIdType = passengerIdType;
    }

    public String getPassengerIdTypeName() {
        return passengerIdTypeName;
    }

    public void setPassengerIdTypeName(String passengerIdTypeName) {
        this.passengerIdTypeName = passengerIdTypeName;
    }

    public String getPassengerIdNo() {
        return passengerIdNo;
    }

    public void setPassengerIdNo(String passengerIdNo) {
        this.passengerIdNo = passengerIdNo;
    }

    public String getPassengerPhoneNo() {
        return passengerPhoneNo;
    }

    public void setPassengerPhoneNo(String passengerPhoneNo) {
        this.passengerPhoneNo = passengerPhoneNo;
    }
    
    public static String generateTicketInfoOnlyId(List<OrderTicketInfo> ticketsInfo) {
        return "sdAdd_" + generateTicketInfoId(ticketsInfo);
    }

    private static int generateTicketInfoId(List<OrderTicketInfo> ticketsInfo) {
        if (ticketsInfo.size() < 1) {
            return ticketsInfo.size();
        } else {
            int id = 0;
            for (OrderTicketInfo ticketInfo : ticketsInfo) {
                int ticketInfoId = Integer.parseInt(ticketInfo.getOnlyId().split("_")[1]);
                if (ticketInfoId > id) {
                    id = ticketInfoId;
                }
            }
            return id + 1;
        }
    }
    
    public static String getValidSeatMark(QueryLeftNewDTO queryLeftNewDTO) {
        String yzNum = queryLeftNewDTO.getYzNum();
        String rzNum = queryLeftNewDTO.getRzNum();
        String ywNum = queryLeftNewDTO.getYwNum();
        String rwNum = queryLeftNewDTO.getRwNum();
        String grNum = queryLeftNewDTO.getGrNum();
        String zeNum = queryLeftNewDTO.getZeNum();
        String zyNum = queryLeftNewDTO.getZyNum();
        String tzNum = queryLeftNewDTO.getTzNum();
        String swzNum = queryLeftNewDTO.getSwzNum();
        String wzNum = queryLeftNewDTO.getWzNum();
        
        if (!"--".equals(yzNum)) {
            return "YZ";
        }
        if (!"--".equals(zeNum)) {
            return "ZE";
        }
        if (!"--".equals(ywNum)) {
            return "YW";
        }
        if (!"--".equals(zyNum)) {
            return "ZY";
        }
        if (!"--".equals(rzNum)) {
            return "RZ";
        }
        if (!"--".equals(rwNum)) {
            return "RW";
        }
        if (!"--".equals(tzNum)) {
            return "TZ";
        }
        if (!"--".equals(grNum)) {
            return "GR";
        }
        if (!"--".equals(swzNum)) {
            return "SWZ";
        }
        if (!"--".equals(wzNum)) {
            return "WZ";
        }
        return "";
    }
    
    public static String getSeatType(String seatTypeMark) {
        switch (seatTypeMark) {
            case "ZY":
                return "M";
            case "ZE":
                return "0";
            case "SWZ":
                return "9";
            case "TZ":
                return "P";
            case "YZ":
                return "1";
            case "RZ":
                return "2";
            case "YW":
                return "3";
            case "RW":
                return "4";
            case "GR":
                return "6";
            case "WZ":
                return "WZ";
        }
        return "";
    }
    
    public static String getSeatTypeName(String seatTypeMark) {
        switch (seatTypeMark) {
            case "ZY":
                return "一等座";
            case "ZE":
                return "二等座";
            case "SWZ":
                return "商务座";
            case "TZ":
                return "特等座";
            case "YZ":
                return "硬座";
            case "RZ":
                return "软座";
            case "YW":
                return "硬卧";
            case "RW":
                return "软卧";
            case "GR":
                return "高级软卧";
            case "WZ":
                return "无座";
        }
        return "";
    }
    
    public static String getTicketTypeName(String passengerTypeValue) {
        switch(passengerTypeValue) {
            case "1":
                return "成人票";
            case "2":
                return "儿童票";
            case "3":
                return "学生票";
            case "4":
                return "残军票";
        }
        return "";
    }

    @Override
    public String toString() {
        return "TicketInfo{" + "name=" + passengerName + ", idType=" + passengerIdType + ", idNo=" + passengerIdNo + ", phoneNo=" + passengerPhoneNo + '}';
    }
}
